package com.lujieni.netty.c3;

import java.util.concurrent.*;


public class TestJdkFuture {

    public static void main(String[] args) {

        ExecutorService executorService = Executors.newFixedThreadPool(2);

        Future<Integer> future = executorService.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                TimeUnit.SECONDS.sleep(2);
                return 5;
            }
        });

        try {
            Integer o = future.get(); //asynchronous blocking
            System.out.println(o);
            executorService.shutdown();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }


    }

}
